<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>站主登录</title>
</head>
<link rel="stylesheet" href="css/modules/code.css">
<link rel="stylesheet" href="css/modules/laydate/default/laydate.css">
<link rel="stylesheet" href="css/modules/layer/default/layer.css">
<link rel="stylesheet" href="css/layui.css">
<link rel="stylesheet" href="css/backRegistered.css">

<body>
  
<div id="back_reistereds">

    <div id="back_reistereds_farme">
        <p id="back_reister_p1">
            站主登录
        </p>
        <form id="loginFroms">
        <p id="reister_p2">
            <input type="text" id="backaccount" name="accounts" required lay-verify="required" placeholder="输入账号" autocomplete="off" class="layui-input">    
        </p>
        
        <p id="reister_p3">
            <input type="text" id="backpwd" name="PassWords" required lay-verify="required" placeholder="输入密码" autocomplete="off" class="layui-input"> 
        </p>
        <button type="button" id="back_gologin"class="layui-btn layui-btn-radius layui-btn-primary" onclick="backlogin()">登录</button>
        <button type="button" id="back_gocancle"class="layui-btn layui-btn-radius layui-btn-primary" onclick="quters()">取消</button>
    </form>
    </div><!-- reistereds_farme -->  
</body>
<script src="js/jquery-3.6.0.min.js"></script>
<script>

function quters(){
    window.location.href = '/'
}


function backlogin(){
    let backaccount = $('#backaccount').val();
    let backpwd = $('#backpwd').val();
    console.log(backaccount);
    console.log(backpwd);
    if(backaccount.length > 0 && backpwd.length > 0){
        $.ajax({
            url:"/backloginDome",
            type:"POST",
            data:$('#loginFroms').serialize(),
            dataType:"json",
            success:function (res) {
                console.log(res);
                if(res.code === 1000) {
                    window.location.href = "/backindex";
                }else{
                    alert("请输入正确的账号或密码") 
                }
            }
        })
    }else{
        alert('登录失败')
    }
};
    </script>
</html>